//waiting.cpp -- using clock() in a time-delay loop
//textin3.cpp -- reading chars to end of file

#include <iostream>
#include <ctime> //describes clock() function , clock_t type

void Example_5_14();
void Example_5_18();

//int main()
//{
//	Example_5_18();
//	return 0;
//}

void Example_5_14()
{
	using namespace std;
	cout << "Enter the delay time, in seconds: ";
	float secs;
	cin >> secs;
	clock_t delay = secs * CLOCKS_PER_SEC; // convert to clock ticks
	cout << "starting\a\n";
	clock_t start = clock();
	while (clock() - start < delay)         //wait until time elapses
		;                                    // note the semicolon
	cout << "done \a\n";
	return;
}

void Example_5_18()
{
	using namespace std;
	char ch;
	int count = 0;
	cin.get(ch);         //attempt to read a char 
	while (cin)          //page156  more useful
	{
		cout << ch;  //echo character
		++count;
		cin.get(ch); //attempt to read another char
	}
	cout << endl << count << " charactors read\n";
	return;
}